<template>
  <div class="l-echart-scrollrank"
       :style="styleSizeName"
       @click="handleClick">
       <div style="width: 100%; height: 100%; display:flex;align-items: center;justify-content: center;">
        <i class="el-icon-time" :style="styleImgName"></i>
       </div>
    
  </div>
</template>

<script>
import init from "../mixins/common";
export default {
    mixins:[init],
    data () {
    return {
      check: null
    };
  },
  computed: {
     styleImgName() {
      return Object.assign({
        fontSize: "80px",
        transitionProperty: "all",
        opacity: this.option.opacity / 100,
        transform: `rotateX(${this.option.rotateX}deg) rotateY(${this.option.rotateY}deg) rotateZ(${this.option.rotateZ}deg) scale(${this.option.scale})`,
      });
    },
    animateValue: {
      get() {
        return this.option.animateValue;
      },
      set() {},
    },
    intervalTime () {
      return this.option.time;
    }
  },
  watch: {
    intervalTime: {
      handler (val) {
        if (val > 0) {
          setTimeout(() => {
            this.startTime()
          }, 1000)
        } else {
          this.stopTime();
        }
      },
      immediate: true

    }
  },
  created() {
        if (!this.option.opacity) this.$set(this.option, 'opacity', 100)
    },
  mounted () {
    this.echartFormatter && this.echartFormatter(this.getItemRefs());
  },
  methods: {
    updateChart() {
        if (this.intervalTime > 0) {
          setTimeout(() => {
            this.startTime()
          }, 1000)
        } else {
          this.stopTime();
        }
    },
    startTime () {
      this.stopTime()
      this.check = setInterval(() => {
        this.echartFormatter && this.echartFormatter(this.getItemRefs());
      }, this.intervalTime)
    },
    stopTime () {
      clearInterval(this.check)
    },
    handleClick() {
      this.clickFormatter &&
        this.clickFormatter(
          {
            data: this.dataChart,
          },
          this.getItemRefs()
        );
    },
  },
};
</script>